<template>
  <d2-container>
    <div class="d2-breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>每月荣誉榜</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-form :inline="true" class="SearchForm">
      <el-form-item label="筛选时间">
        <el-date-picker
          v-model="searchForm.createTime"
          type="month"
          placeholder="选择日期时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-button type="primary" @click="search()" icon="el-icon-search"
        >查询</el-button
      >
      <el-button type="danger" icon="el-icon-refresh" @click="reset"
        >重置</el-button
      >
    </el-form>

    <el-row :gutter="20">
      <el-col :span="10">
        <h2>园区拓展榜</h2>
        <el-table border :data="tableData1.list">
          <el-table-column
            label="排名"
            align="center"
            type="index"
          ></el-table-column>
          <el-table-column
            label="加盟商名称"
            align="center"
            prop="franchName"
          ></el-table-column>
          <el-table-column
            label="拓展数量"
            align="center"
            prop="num"
          ></el-table-column>
        </el-table>
      </el-col>
      <el-col :span="10">
        <h2>企业拓展榜</h2>
        <el-table border :data="tableData2.list">
          <el-table-column
            label="排名"
            align="center"
            type="index"
          ></el-table-column>
          <el-table-column
            label="加盟商名称"
            align="center"
            prop="franchName"
          ></el-table-column>
          <el-table-column
            label="拓展数量"
            align="center"
            prop="num"
          ></el-table-column>
        </el-table>
      </el-col>
    </el-row>
  </d2-container>
</template>

<script>
export default {
  data() {
    return {
      searchForm: {},
      tableData1: {
        list: [],
        total: 0,
      },
      tableData2: {
        list: [],
        total: 0,
      },
      page: 1,
      pageSize: 99999,
    };
  },
  methods: {
    search1() {
      let params = {
        pageNum: this.page,
        pageSize: this.pageSize,
        ...this.searchForm,
      };
if (params.createTime) {
        params.createTime = new Date(
          Date.parse(new Date(params.createTime)) + 8 * 3600 * 1000
        );
      }
      this.$axios.post("/sysGardenGrant/gardenList", params).then((result) => {
        if (result) {
          this.tableData1 = {
            list: result.data.list,
            total: result.data.total,
          };
        } else {
          this.$message.error(result.data.msg);
        }
      });
    },
    search2() {
      let params = {
        pageNum: this.page,
        pageSize: this.pageSize,
        ...this.searchForm,
      };

      this.$axios
        .post("/sysGardenGrant/enterpriseList", params)
        .then((result) => {
          if (result) {
            this.tableData2 = {
              list: result.data.list,
              total: result.data.total,
            };
          } else {
            this.$message.error(result.data.msg);
          }
        });
    },
    search() {
      this.search1();
      this.search2();
    },
    reset() {
      this.searchForm = {};
      this.search();
    },
  },
  mounted(){
      this.search();
  }
};
</script>

<style>
</style>